//
//  UIBarButtonItem+HMXBarButton.m
//  HMXBaisi
//
//  Created by apple on 16/6/15.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "UIBarButtonItem+HMXBarButton.h"

@implementation UIBarButtonItem (HMXBarButton)

+(instancetype)barButtonItemWithImage:(UIImage *)image HighImage:(UIImage *)highImage target:(id)target action:(SEL)action
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:highImage forState:UIControlStateHighlighted];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIView * btnView = [[UIView alloc]initWithFrame:btn.frame];
    [btnView addSubview:btn];
    
    return [[UIBarButtonItem alloc]initWithCustomView:btnView];
    
}

+(instancetype)barButtonItemWithImage:(UIImage *)image SelImage:(UIImage *)selImage target:(id)target action:(SEL)action
{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:selImage forState:UIControlStateSelected];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView * btnView = [[UIView alloc]initWithFrame:btn.frame];
    [btnView addSubview:btn];
    return [[UIBarButtonItem alloc]initWithCustomView:btnView];
}

@end
